<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'request'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-view onekit-class="page-body-wording">
			<onekit-text onekit-class="page-body-text">点击向服务器发起请求</onekit-text>
		</onekit-view>
		<onekit-view onekit-class="btn-area">
			<onekit-button type="primary" :disabled="buttonDisabled" :loading="loading" @Tap="makeRequest">request</onekit-button>
		</onekit-view>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "网络请求",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
const requestUrl = require('../../../config').requestUrl;
const duration = 2000;
export default Page(ONEKIT_JSON,["buttonDisabled","loading"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'网络请求',
        "path":'packageAPI/pages/request/request'
};
    },
    "makeRequest"(){
      const self = this;
      self.setData({
        "loading":true
});
      wx.request({
        "url":requestUrl,
        "data":{
            "noncestr":Date.now()
},
        "success"(result){
          wx.showToast({
            "title":'请求成功',
            "icon":'success',
            "mask":true,
            duration
});
          self.setData({
            "loading":false
});
          console.log('request success',result);
        },
        "fail"({errMsg}){
          console.log('request fail',errMsg);
          self.setData({
            "loading":false
});
        }
});
    }
});

</script>
<style 
 lang="css">
</style>